home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PASCALL / NEETVGA / ROG / 320X200.PAS next >
Pascal/Delphi Source File  |  1992-09-29  |  3KB  |  72 lines

  1. var
  2.   GraphDriver : integer;  { The Graphics device driver }
  3.   GraphMode   : integer;  { The Graphics mode value }
  4.   MaxX, MaxY  : word;     { The maximum resolution of the screen }
  5.   ErrorCode   : integer;  { Reports any graphics errors }
  6.   MaxColor    : word;     { The maximum color value available }
  7.   OldExitProc : Pointer;  { Saves exit procedure address }
  8.  
  9. {$F+}
  10. procedure MyExitProc;
  11. begin
  12.   ExitProc := OldExitProc; { Restore exit procedure address }
  13.   CloseGraph;              { Shut down the graphics system }
  14. end; { MyExitProc }
  15. {$F-}
  16.  
  17. {$F+}
  18. function DetectVGA256 : integer;
  19. { Detects VGA or MCGA video cards }
  20. var
  21.   DetectedDriver : integer;
  22.   SuggestedMode  : integer;
  23. begin
  24.   DetectGraph(DetectedDriver, SuggestedMode);
  25.   if (DetectedDriver = VGA) or (DetectedDriver = MCGA) then
  26.     DetectVGA256 := 0        { Default video mode = 0 }
  27.   else
  28.     DetectVGA256 := grError; { Couldn't detect hardware }
  29. end; { DetectVGA256 }
  30. {$F-}
  31.  
  32. var
  33.   AutoDetectPointer : pointer;
  34.  
  35. procedure Initialize320x200;
  36. { Initialize graphics and report any errors that may occur }
  37. var
  38.   InGraphicsMode : boolean; { Flags initialization of graphics mode }
  39.   PathToDriver   : string;  { Stores the DOS path to *.BGI & *.CHR }
  40. begin
  41.   { when using Crt and graphics, turn off Crt's memory-mapped writes }
  42.   DirectVideo := False;
  43.   OldExitProc := ExitProc;                { save previous exit proc }
  44.   ExitProc := @MyExitProc;                { insert our exit proc in chain }
  45.   PathToDriver := '';
  46.   repeat
  47.  
  48.     AutoDetectPointer := @DetectVGA256;   { Point to detection routine }
  49.     GraphDriver := InstallUserDriver('SVGA256', AutoDetectPointer);
  50.     GraphDriver := Detect;
  51.  
  52.     InitGraph(GraphDriver, GraphMode, PathToDriver);
  53.     ErrorCode := GraphResult;             { preserve error return }
  54.     if ErrorCode <> grOK then             { error? }
  55.     begin
  56.       Writeln('Graphics error: ', GraphErrorMsg(ErrorCode));
  57.       if ErrorCode = grFileNotFound then  { Can't find driver file }
  58.       begin
  59.         Writeln('Enter full path to BGI driver or type <Ctrl-Break> to quit:');
  60.         Readln(PathToDriver);
  61.         Writeln;
  62.       end
  63.       else
  64.         Halt(1);                          { Some other error: terminate }
  65.     end;
  66.   until ErrorCode = grOK;
  67.   Randomize;                { init random number generator }
  68.   MaxColor := GetMaxColor;  { Get the maximum allowable drawing color }
  69.   MaxX := GetMaxX;          { Get screen resolution values }
  70.   MaxY := GetMaxY;
  71. end; { Initialize }
  72.